Imports System.IO

Public Class Fitxers
    Public Function FitxerBase() As String
        Dim base As String = My.Settings.subDirBase
        Dim arrel2 As String = My.Computer.FileSystem.CurrentDirectory
        Return My.Computer.FileSystem.CombinePath(arrel2, base)
    End Function



    Public Function LlistatFitxers(ByVal Path As String) As DataTable
        Dim table As New DataTable
        Dim di As New IO.DirectoryInfo(Path)
        Dim diar1 As IO.FileInfo() = di.GetFiles()
        Dim dra As IO.FileInfo

        'list the names of all files in the specified directory

        table.Columns.Add("nom", GetType(System.String))
        table.Columns.Add("dataModificacio", GetType(Date))
        For Each dra In diar1
            table.Rows.Add(dra.Name, dra.LastAccessTime)
        Next
        Return table
    End Function
    Public Function LlistatDirectoris(ByVal Path As String) As DataTable
        Dim table As New DataTable
        Dim di As New IO.DirectoryInfo(Path)
        Dim diar1 As IO.DirectoryInfo() = di.GetDirectories()
        Dim dra As IO.DirectoryInfo

        'list the names of all files in the specified directory

        table.Columns.Add("nom", GetType(System.String))
        table.Columns.Add("dataModificacio", GetType(Date))
        For Each dra In diar1
            table.Rows.Add(dra.Name, dra.LastAccessTime)
        Next
        Return table
    End Function
    Public Function LleguirFitxer(ByVal Path As String) As String
        Dim s As String
        Dim lector As New StreamReader(My.Computer.FileSystem.CombinePath(Path, "sample.txt"))
        s = lector.ReadToEnd
        Return s
    End Function

End Class
